import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Bar-SnackBar-屏幕底部消息',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(title: Text('Bar-SnackBar-屏幕底部消息'),),
        body: DemoPage(),
      ),
    );
  }
}

class DemoPage extends StatefulWidget{
  @override
  DemoPageState createState() => DemoPageState();
}

class DemoPageState extends State<DemoPage>{
  @override
  Widget build(BuildContext context) {
    return Center(
      child: GestureDetector(
          onTap:(){
            final snackBar = SnackBar(content: Text('SnackBar'),
              backgroundColor: Colors.green,
              action: SnackBarAction(
                label: 'cancle',
                onPressed: (){

                },
              ),
              duration: Duration(minutes: 1),
            );
            //展示snackBar
            Scaffold.of(context).showSnackBar(snackBar);
            },
        child: Text('bottom'),
      ),
    );
  }
}